// getToken.js

function getVideoToken(callBack){
	var nowTime = new Date().getTime();
	var ak = "ab64a3135e6003a5d6e2bb27f655b8ab";
	var sk = "c0f9a26c976f1413";
	var time = nowTime.toString();
	var token = MD5(ak+time+sk)+'_'+time+'_'+ak;
	var params = {
		token : token,
		mediaId : "jfskjfasjlkje230945u23dsga"
	};
	cfnetppPOST(url_getVideoTokenUrl, params, false, function(data, status){
		if (status == 'success') {
			if (data.code == 200) {
				callBack(true, data.data);
			}else{
				callBack(false, '');
			}
		}else{
			callBack(false, '');
		}
	});
}
function pushToBaiDuPlayer(is_encr, baidu_cloud_id_url, path, title){
	if(path != null && path != '' && path.indexOf("http://") < 0 ){
		path = 'http://bos.cfnet.org.cn' + path;
	} 
	var videoPath = path;
	if (path != '') {
		var CFBaiDuVideo = api.require('CFBaiDuVideo');
	    CFBaiDuVideo.initVideo({
	       title : title,
	       path : videoPath,
	       isShowFullScreenBtn : 1,
	       isShowFullScreen : 1,
	       token : ''
	    },function(ret, err){
	    });
	}else{
		if (is_encr == 1) {//加密
			videoPath = baidu_cloud_id_url;
			getVideoToken(function(status, videoToken){
				var CFBaiDuVideo = api.require('CFBaiDuVideo');
		        CFBaiDuVideo.initVideo({
		           title : title,
		           path : videoPath,
		           isShowFullScreenBtn : 1,
		           isShowFullScreen : 1,
		           token : videoToken
		        },function(ret, err){
		        });
		    });
		}else{
			api.toast({
			    msg: '视频播放失败！'
			});
		}
	}
}